﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using University.Workshop.Model;
using University.Workshop.DataAccess;

namespace University.Workshop.Business
{
    public static class AppointmentManager
    {
        /// <summary>
        /// Verifies if the input data is correct
        /// </summary>
        /// <param name="idPatient">patient id</param>
        /// <param name="idDoctor">Doctor id</param>
        /// <param name="date">date</param>
        /// <param name="time">time</param>
        /// <returns>Returns True if the inputs are correct</returns>
        public static bool AreInputsCorrect(string idPatient, string idDoctor,string date, string time)
        {
            if (!string.IsNullOrEmpty(idPatient) && !string.IsNullOrEmpty(idDoctor) && !string.IsNullOrEmpty(date) && !string.IsNullOrEmpty(time))
                return true;
            else
                return false;
        }

        /// <summary>
        /// This Method manage the new Appointment to be Register
        /// </summary>
        /// <param name="newAppointment">The new Appointment</param>
        /// <returns>Returns true if the appointment was succesfully inserted</returns>
        public static bool RegisterAppointment(Appointment newAppointment)
        {
            return AppointmentDataAccess.InsertNewAppointment(newAppointment);
        }

        public static ICollection<Appointment> SearchAppointment(string patientId)
        {
            return AppointmentDataAccess.SearchAppointment(patientId);
        }


        public static ICollection<Appointment> GetAppointmentsByDay(string date)
        {
            return DataAccess.AppointmentDataAccess.GetAppointmentsByDate(date);
        }

        public static ICollection<MedicalSupplies> GetMedicalSuppliesByPatientId(string id)
        {
            return MedicalSuppliesDataAccess.GetMedicalSuppliesForName(id);
        }
        public static void ModifyAppointment(Appointment apo)
        {
            //      if (Quantity == string.Empty)
            //          throw new Exception("debe llenar el campo a actualizar");
            //      else
            //      {
            //          int j;
            //         j=int.Parse(Quantity);

            AppointmentDataAccess.ModifyAppointmentDate(apo);
        }

        public static ICollection<Appointment> GetAppointmentsToday(string doctorId, string dateToday)
        {
            return AppointmentDataAccess.GetAppointmentsToday(doctorId, dateToday);
        }



        public static ICollection<Appointment> GetPostponedAppointments(string doctorId)
        {
            return AppointmentDataAccess.GetPostponedAppointments(doctorId);
        }

        public static ICollection<Appointment> AppointmentReminder(string dateTomorrow)
        {
            return AppointmentDataAccess.AppointmentReminder(dateTomorrow);
        }
    }
}
